package com.knight.thread;

import java.util.concurrent.Callable;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadPoolExcutorTest {

	public static void main(String[] args) {
		ThreadPoolExecutor pool = new ThreadPoolExecutor(1, 5, 5000, TimeUnit.SECONDS, new LinkedBlockingDeque<>(50));
		
		for(int i=0; i<20; i++) {
			pool.submit(new Callable<String>() {
				@Override
				public String call() throws Exception {
					TimeUnit.SECONDS.sleep(2);
					return Thread.currentThread().getName();
				}
			});
			System.out.println("当前线程池大小：" + pool.getPoolSize() + "当前队列大小：" +pool.getQueue().size());
		}

	}

}
